home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
-
- Common Stuff.h
-
- This is a standard set of includes and macros that are defined for all of the RAVE
- projects, including error checking code and debugging features.
-
- Author: Timothy Carroll
- Apple Developer Technical Support
- timc@apple.com
-
- Modification History:
-
- 5/1/98 TMC Initial Release
-
- Copyright © 1996 Apple Computer, Inc., All Rights Reserved
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
- *************************************************************************************/
-
- #ifndef _COMMONSTUFF_
- #define _COMMONSTUFF_
-
- #pragma once
-
- // RAVE needs enums always int to be turned on
- #ifdef __MWERKS__
-
- #if !__option (enumsalwaysint)
- #error "Enums must be always int for RAVE to work properly"
- #endif
- #endif
-
- /*********************************************************************************
- # ERROR HANDLING MACROS
- #
- # These macros can be used to implement nice error handling within a function.
- # Essentially, all errors jump to an error handler at the end of the function, which
- # should cleanup any leftovers and return the appropriate error result.
- #
- # Note that the error handlers take a message string. This should be a good
- # indication of the actual error, and it will appear when debugging is turned on.
- #
- # The qDebugging macro can be used to implement sanity checking code that is only
- # compiled into debug builds.
- #
-
- #if qDebugging
- // do additional sanity checking here.
- #endif
- #
- # This could be used to check the internal validity of an object before acting on it
- #
- *********************************************************************************/
- #ifndef qDebugging
- #define qDebugging 1
- #endif
-
- #if qDebugging
- #define SIGNAL_ERROR(msg) {DebugStr(msg); goto error;}
- #else
- #define SIGNAL_ERROR(msg) {goto error;}
- #endif
-
- #define FAIL_NIL(y,msg) if (y == NULL) SIGNAL_ERROR(msg)
- #define FAIL_OSERR(y,msg) if (y != noErr) SIGNAL_ERROR(msg)
- #define FAIL_FALSE(y,msg) if (!y) SIGNAL_ERROR(msg)
-
-
-
- #endif /* _COMMONSTUFF_ */
-
-
-
-